#include <QKeyEvent>

#include "SudokuCellEditor.h"

SudokuCellEditor::SudokuCellEditor(QWidget* parent) : QLineEdit(parent)
{
    setAlignment(Qt::AlignCenter);
    setContextMenuPolicy(Qt::NoContextMenu);
}

SudokuCellEditor::SudokuCellEditor(const QString& contents, QWidget* parent) : QLineEdit(contents, parent)
{
    setAlignment(Qt::AlignCenter);
    setContextMenuPolicy(Qt::NoContextMenu);
}

void SudokuCellEditor::keyPressEvent(QKeyEvent* event)
{
    // Ignore left and right arrow key to support full keyboard navigation
    // Arrows are handled by SudokuDiagram
    if(event->key() == Qt::Key_Left || event->key() == Qt::Key_Right)
    {
        event->ignore();
    }
    else
    {
        QLineEdit::keyPressEvent(event);
    }
}
